let line1 = '3 4 1 2 5 6 6 1 1 1'

let arr = line1.split(' ')
  arr = arr.map(item => Number(item))
  console.log(arr);
  arr.sort((a, b) => a - b)
  let count = 1
  if(!arr.includes(1)) {
  console.log(0)  
  }
  else {
  for(let i = 1; i < arr.length; i++) {
    if((count + 1) == arr[i]) {
      count = arr[i]
    }
  }
  console.log(count)
}